<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/active_scaffold/lib/data_structures/action_columns_rb.html">
                vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
A package of stuff to add after the configuration block. This is an attempt
at making a certain level of functionality inaccessible during
configuration, to reduce possible breakage from misuse. The bulk of the
package is a means of connecting the referential column set (<a
href="../ActionColumns.html">ActionColumns</a>) with the actual column
objects (<a href="../Columns.html">Columns</a>). This lets us iterate over
the set and yield real column objects.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000368">constraint_columns</a>&nbsp;&nbsp;
      <a href="#M000366">each</a>&nbsp;&nbsp;
      <a href="#M000369">length</a>&nbsp;&nbsp;
      <a href="#M000367">set_columns</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">constraint_columns</td>
          <td class="context-item-value">&nbsp;[W]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000368" class="method-detail">
        <a name="M000368"></a>

        <div class="method-heading">
          <a href="#M000368" class="method-signature">
          <span class="method-name">constraint_columns</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000368-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000368-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb, line 83</span>
83:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">constraint_columns</span>
84:         <span class="ruby-ivar">@constraint_columns</span> <span class="ruby-operator">||=</span> []
85:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000366" class="method-detail">
        <a name="M000366"></a>

        <div class="method-heading">
          <a href="#M000366" class="method-signature">
          <span class="method-name">each</span><span class="method-args">(options = {}) {|item| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Redefine the <a href="AfterConfiguration.html#M000366">each</a> method to
yield actual <a href="../Column.html">Column</a> objects. It will skip
constrained and unauthorized columns.
</p>
<p>
Options:
</p>
<pre>
 * :flatten - whether to recursively iterate on nested sets. default is false.
 * :for - the record (or class) being iterated over. used for column-level security. default is the class.
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000366-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000366-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb, line 52</span>
52:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
53:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:for</span>] <span class="ruby-operator">||=</span> <span class="ruby-ivar">@columns</span>.<span class="ruby-identifier">active_record_class</span>
54: 
55:         <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
56:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">ActiveScaffold</span><span class="ruby-operator">::</span><span class="ruby-constant">DataStructures</span><span class="ruby-operator">::</span><span class="ruby-constant">ActionColumns</span>
57:             <span class="ruby-identifier">item</span> = (<span class="ruby-ivar">@columns</span>[<span class="ruby-identifier">item</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ActiveScaffold</span><span class="ruby-operator">::</span><span class="ruby-constant">DataStructures</span><span class="ruby-operator">::</span><span class="ruby-constant">Column</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">item</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-ivar">@columns</span>.<span class="ruby-identifier">active_record_class</span>))
58:             <span class="ruby-comment cmt"># skip if this matches a constrained column</span>
59:             <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">constraint_columns</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">item</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>)
60:             <span class="ruby-comment cmt"># skip if this matches the field_name of a constrained column</span>
61:             <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">field_name</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">constraint_columns</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">item</span>.<span class="ruby-identifier">field_name</span>.<span class="ruby-identifier">to_sym</span>)
62:             <span class="ruby-comment cmt"># skip this field if it's not authorized</span>
63:             <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:for</span>].<span class="ruby-identifier">authorized_for?</span>(<span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">action</span>.<span class="ruby-identifier">crud_type</span>, <span class="ruby-identifier">:column</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">name</span>)
64:           <span class="ruby-keyword kw">end</span>
65:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">ActiveScaffold</span><span class="ruby-operator">::</span><span class="ruby-constant">DataStructures</span><span class="ruby-operator">::</span><span class="ruby-constant">ActionColumns</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:flatten</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:flatten</span>]
66:             <span class="ruby-identifier">item</span>.<span class="ruby-identifier">each</span>(<span class="ruby-identifier">options</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc</span>)
67:           <span class="ruby-keyword kw">else</span>
68:             <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">item</span>
69:           <span class="ruby-keyword kw">end</span>
70:         <span class="ruby-keyword kw">end</span>
71:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000369" class="method-detail">
        <a name="M000369"></a>

        <div class="method-heading">
          <a href="#M000369" class="method-signature">
          <span class="method-name">length</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000369-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000369-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb, line 87</span>
87:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">length</span>
88:         (<span class="ruby-ivar">@set</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">constraint_columns</span>).<span class="ruby-identifier">length</span>
89:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000367" class="method-detail">
        <a name="M000367"></a>

        <div class="method-heading">
          <a href="#M000367" class="method-signature">
          <span class="method-name">set_columns</span><span class="method-args">(columns)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
registers a set of column objects (recursively, for all nested <a
href="../ActionColumns.html">ActionColumns</a>)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000367-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000367-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb, line 74</span>
74:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_columns</span>(<span class="ruby-identifier">columns</span>)
75:         <span class="ruby-ivar">@columns</span> = <span class="ruby-identifier">columns</span>
76:         <span class="ruby-comment cmt"># iterate over @set instead of self to avoid dealing with security queries</span>
77:         <span class="ruby-ivar">@set</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
78:           <span class="ruby-identifier">item</span>.<span class="ruby-identifier">set_columns</span>(<span class="ruby-identifier">columns</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:set_columns</span>
79:         <span class="ruby-keyword kw">end</span>
80:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>